package com.cuit.jifver.weibo.activity;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.widget.TextView;

import com.cuit.jifver.weibo.logic.MainService;


public abstract class BaseActivity extends Activity{
	
	public static final int CONTINUOUS_SCAN_RESULT = 10;
	
	private Context context;
	private TextView noItem,refresh;
	private int layoutId;	
	protected ProgressDialog progress;
	
	
    @Override
	protected void onCreate(Bundle savedInstanceState) {
    	requestWindowFeature(Window.FEATURE_NO_TITLE);
		MainService.allActivity.add(this);
		super.onCreate(savedInstanceState);
	}
       
  //  public abstract void init();
    public abstract void refresh(Object ...param);
    
    public boolean checkRequiredLogin(String errorCode)
    {
    	if(errorCode.equals("LoginRequired"))
    	{
    		return true;
    	}else
    		return false;
    }
    

    
	@Override
	public void setContentView(int layoutResID) {
		layoutId = layoutResID;
		super.setContentView(layoutResID);
	}

	@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);

//        menu.add(0, 0, 0, "Home").setIcon(R.drawable.hometabicon);
//        menu.add(0, 1, 1, "Shop").setIcon(R.drawable.shoptabicon);
//        menu.add(0, 2, 2, "Deals").setIcon(R.drawable.dealstabicon);
//        menu.add(0, 3, 3, "MyList").setIcon(R.drawable.mylisttabicon);
//        menu.add(0, 4, 4, "Cart").setIcon(R.drawable.carttabicon);
        return true;
    }

    @Override
    public boolean onMenuItemSelected(int featureId, MenuItem item) {
        switch (item.getItemId()) {
//            case 0:
//                HomeActivity();
//                break;
//            case 1:
//            	GotoShopActivity();
//                break;
//            case 2:
//            	GotoDealActivity();
//                break;
//            case 3:
//            	GotoMyListActivity();
//                break;
//            case 4:
//            	GotoCartActivity();
//                break;
//            default:
//            	break;
        }
        return super.onMenuItemSelected(featureId, item);
    }    

    private void LocateMe()
    {
        //TODO: call GPS to locate me
    }
    
    public void showProgress(String title)
    {
		if(null == progress)
		{
			progress = new ProgressDialog(this);	
			progress.setCancelable(false);
		}
		
		if (title == null)
		{
			title = "loading please wait";
		}
		
		progress.setMessage(null);
		
		if (!progress.isShowing())
		{
			progress.show();
		}
		
	}
	
    public void showProgress(int flag){
    	switch(flag){
//    	case 0:
//    		if(null == progress0){
//    			progress0 = new CustomProgressDialog(this,R.style.dialog);
//   			    progress0.setBackGround(R.drawable.ms_loading);
//   			    progress0.setCancelable(false);
//    		}    		
//    		
//    		progress0.show();
//    		
//    		break;
//    	case 1:
//    		showProgress();
//    		break;
    	}
    }
    
    
	public void dismissProgress()
	{	    
		if(null!=progress && progress.isShowing())
		{
	    	progress.dismiss();
	    }
		
	}
    
    public Context getContext()
    {
    	return BaseActivity.this;
    }

	@Override
	protected void onResume() 
	{
		super.onResume();
	}
    

}
